package StackAndQueuePackage2;

import java.util.Stack;

/**
 * @author Lzm
 * @version 1.0
 */
public class MyQueue_ {
  Stack<Integer> stack1 = new Stack<>();
  Stack<Integer> stack2 = new Stack<>();
  public MyQueue_(){}
  public void push(int number){
    stack1.push(number);
  }
  public int pop(){
    if (stack2.isEmpty()){
      while(!stack1.isEmpty()){
        stack2.push(stack1.pop());
      }
    }
    return stack2.pop();
  }
  public int peek(){
    if (stack2.isEmpty()){
      while(!stack1.isEmpty()){
        stack2.push(stack1.pop());
      }
    }
    return stack2.peek();
  }
  public boolean empty(){
    return stack1.isEmpty() && stack2.isEmpty();
  }

}
